{extend name='admin@main'}

{block name="content"}
<table class="layui-table" lay-skin="line">
    <caption class="margin-bottom-10 text-left">{include file='order/index_search'}</caption>
    <!--{notempty name='list'}-->
    <thead>
    <tr>
        <th class='list-table-check-td think-checkbox'>
            <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
        </th>
        <th class="text-left nowrap">用户信息</th>
        <th class='text-left nowrap'>订单信息</th>
        <th class='text-left nowrap'>个人资料</th>
        <th class='text-right nowrap'>产品信息</th>
    </tr>
    </thead>
    <!--{/notempty}-->
    <tbody>
    <!--{foreach $list as $key=>$vo}-->
    <tr>
        <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
        <td class="text-left nowrap relative">
            {notempty name='vo.member.headimg'}
            <img data-tips-image style="width:80px;height:80px" src="{$vo.member.headimg|default=''}" class="margin-right-5 text-top">
            {/notempty}
            <div class="inline-block">
                会员昵称：{$vo.member.nickname|default='--'}<br>
                open_id：{$vo.member.openid|default='--'}<br>
                创建时间：{$vo.member.create_at|default='--'}<br>
            </div>
        </td>
        <td class='text-left nowrap'>
            订单单号：<span class="color-blue">{$vo.order_sn|default=''}</span>
            {if $vo['order_type'] == 1}
            {eq name='vo.status' value='0'}<span class="layui-badge layui-bg-red margin-left-5">已取消</span>{/eq}
            {eq name='vo.status' value='1'}<span class="layui-badge layui-bg-red margin-left-5">预订单待补全</span>{/eq}
            {eq name='vo.status' value='2'}<span class="layui-badge layui-bg-orange margin-left-5">新订单待支付</span>{/eq}
            {eq name='vo.status' value='3'}<span class="layui-badge layui-bg-black margin-left-5">已支付待审核</span>{/eq}
            {eq name='vo.status' value='4'}<span class="layui-badge layui-bg-green margin-left-5">充值成功</span>{/eq}
            {eq name='vo.status' value='5'}<span class="layui-badge layui-bg-blue margin-left-5">审核未通过</span>{/eq}
             {else/}
            {eq name='vo.status' value='0'}<span class="layui-badge layui-bg-red margin-left-5">已取消</span>{/eq}
            {eq name='vo.status' value='1'}<span class="layui-badge layui-bg-red margin-left-5">预订单待补全</span>{/eq}
            {eq name='vo.status' value='2'}<span class="layui-badge layui-bg-orange margin-left-5">新订单待支付</span>{/eq}
            {eq name='vo.status' value='3'}<span class="layui-badge layui-bg-black margin-left-5">已支付待审核</span>{/eq}
            {eq name='vo.status' value='4'}<span class="layui-badge layui-bg-green margin-left-5">审核通过</span>{/eq}
            {eq name='vo.status' value='5'}<span class="layui-badge layui-bg-blue margin-left-5">审核未通过</span>{/eq}
            {/if}
            <br>
            订单金额：<strong class="color-blue">{$vo.price+0}</strong> 元
            已支付 <strong class="color-blue">{$vo.pay_price+0}</strong> 元
            优惠金额 <strong class="color-blue">{$vo.reduced_price+0}</strong> 元<br>
            {if !empty($vo['couponsInfo'])}
                 优惠券信息：{$vo['couponsInfo']['name']}, {$vo['couponsInfo']['coupons_code']}
            <br>
            {/if}
            {if $vo['use_card_value'] > 0}
            使用储值金额：{$vo['use_card_value']} 元
            <br>
            {/if}
            下单时间：{$vo.create_time|format_datetime}<br>
            支付时间：{$vo.pay_at|format_datetime|default='--'}<br>
        </td>
        <td class="text-left nowrap">
            {if isset($vo['info'])}
            <span>
                真实姓名：{$vo['info']['real_name']|default='--'}
            </span>
            <br>
            <span>
                手机号：{$vo['info']['mobile']|default='--'}
            </span>
            <br>
            <span>
                身份证号：{$vo['info']['id_card']|default='--'}
            </span>
            {if !empty($vo['member_address_id'])}
            <br>
            地址信息：<a href="javascript:void(0)" data-modal='{:url("showAddress")}?id={$vo["member_address_id"]}' data-title="地址信息">查看地址信息</a>
            {/if}
            <br>
            更多操作：<a href="javascript:void(0)" data-modal='{:url("showDetail")}?id={$vo["info"]["id"]}' data-title="个人详细信息">查看详细信息</a>&nbsp;&nbsp;&nbsp;
            {else/}
               暂未完善
            {/if}
            {eq name='vo.status' value='3'}
            <a href="javascript:void(0)" onclick='checkOrder({$vo["id"]},1)'><span style="color: green">通过审核</span></a>
            &nbsp;&nbsp;<a href="javascript:void(0)" onclick='checkOrder({$vo["id"]},2)'><span style="color: red">审核拒绝</span></a>
            {/eq}
        </td>
        <td class="nowrap">
           {if $vo['order_type'] == 1}
               储值卡充值
            {else/}
            {if isset($vo['activityInfo'])}
            <div class="nowrap">
                <p class="text-right">活动：{$vo['activityInfo']['name']}</p>
            </div>
            {/if}
            {if isset($vo['groupInfo'])}
            <div class="nowrap">
                <p class="text-right">组别：{$vo['groupInfo']['name']}</p>
                <p class="text-right color-desc">
                    价格：{$vo['groupInfo']['price']}元
                </p>
            </div>
            {/if}
            {if isset($vo['packageInfo'])}
            <div class="nowrap">
                <p class="text-right">套餐：{$vo['packageInfo']['name']}</p>
                <p class="text-right color-desc">
                    价格：{$vo['packageInfo']['price']}元
                </p>
            </div>
            {/if}
            {if isset($vo['productData'])}
            <div class="nowrap">
                <p class="text-right">服务选择</p>
                <p class="text-right color-desc">
                    {foreach name="$vo['productData']" item="product"}
                    {$product.name}({$product.attr})
                    {/foreach}
                </p>
            </div>
            {/if}
            {/if}
        </td>
    </tr>
    <!--{/foreach}-->
    </tbody>
</table>

{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

<style>
    table.trim-bottom-border tr:last-child td {
        border: none !important
    }
</style>
{/block}
{block name='script'}
<script>
    function checkOrder(id,type) {
        if(type === 1){
            $.msg.confirm('确定通过审核？',function () {
                let url = "{:url('checkOrder')}";
                let data = {
                    id : id
                }
                $.post(url, data, function (res) {
                    if(res['code']){
                        $.msg.success(res['info']);
                        setTimeout(function () {
                            window.location.href = window.location.href;
                        }, 1500)
                    }else{
                        $.msg.error(res['info']);
                    }
                });
            });
        }else{
            //prompt层
            layer.prompt({title: '请输入未通过理由', formType: 2}, function(pass, index){
                let url = "{:url('checkOrderRefuse')}";
                let data = {
                    id : id,
                    msg: pass
                };
                $.post(url, data, function (res) {
                    if(res['code']){
                        $.msg.success(res['info']);
                        layer.close(index);
                        setTimeout(function () {
                            window.location.href = window.location.href;
                        }, 1500)
                    }else{
                        $.msg.error(res['info']);
                    }
                });
            });
        }
    }
</script>
{/block}